package com.ruoyi.Label.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.Goover.domain.StudyEnglish;
import com.ruoyi.Goover.mapper.StudyEnglishMapper;
import com.ruoyi.Unit.domain.StudyUnit;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Label.domain.StudyLable;
import com.ruoyi.Label.service.IStudyLableService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 存储标签的库Controller
 * 
 * @author luobom
 * @date 2021-12-03
 */
@RestController
@RequestMapping("/Label/Lable")
public class StudyLableController extends BaseController
{
    @Autowired
    private IStudyLableService studyLableService;


    /**
     * 查询存储标签的库列表
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudyLable studyLable)
    {
        startPage();
        List<StudyLable> list = studyLableService.selectStudyLableList(studyLable);
        return getDataTable(list);
    }

    /**
     * 导出存储标签的库列表
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:export')")
    @Log(title = "存储标签的库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudyLable studyLable)
    {
        List<StudyLable> list = studyLableService.selectStudyLableList(studyLable);
        ExcelUtil<StudyLable> util = new ExcelUtil<StudyLable>(StudyLable.class);
        util.exportExcel(response, list, "存储标签的库数据");
    }

    /**
     * 获取存储标签的库详细信息
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:query')")
    @GetMapping(value = "/{uid}")
    public AjaxResult getInfo(@PathVariable("uid") String uid)
    {
        return AjaxResult.success(studyLableService.selectStudyLableByUid(uid));
    }

    /**
     * 新增存储标签的库
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:add')")
    @Log(title = "存储标签的库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudyLable studyLable)
    {
        return toAjax(studyLableService.insertStudyLable(studyLable));
    }

    /**
     * 修改存储标签的库
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:edit')")
    @Log(title = "存储标签的库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudyLable studyLable)
    {
        return toAjax(studyLableService.updateStudyLable(studyLable));
    }

    /**
     * 删除存储标签的库
     */
    @PreAuthorize("@ss.hasPermi('Label:Lable:remove')")
    @Log(title = "存储标签的库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uids}")
    public AjaxResult remove(@PathVariable String[] uids)
    {
        return toAjax(studyLableService.deleteStudyLableByUids(uids));
    }
}
